package com.deyu.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.deyu.base.BaseAction;
import com.deyu.domain.CommenMsg;
import com.deyu.domain.Student;
import com.deyu.util.StrUtil;
import com.opensymphony.xwork2.ActionContext;

@Controller
@Scope("prototype")
@SuppressWarnings("serial")
public class StudentAction extends BaseAction<Student>{
    private CommenMsg commenMsg;
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return super.execute();
	}
    /**
     * 登录界面
     * @return loginUI
     * @throws Exception
     */
	public String loginUI() throws Exception {
	    return "loginUI";
	}
	/**
	 * 登录
	 * @return login
	 * @throws Exception
	 */
	public String login() throws Exception {
		String loginName= request("username");
    	String password = request("password");
    	commenMsg = new CommenMsg();
    	if(loginName!=null&&password!=null){
    		
    		if(studentService.findStudentByLP(loginName,password)!=null){
    			Student student = studentService.findStudentByLP(loginName,password);
    		    ActionContext.getContext().getSession().put("student", student);
    		    return "toIndex";
    		}else{
    			return "loginUI";
    		}
    		   
   
    	}else{
    		return "loginUI";
    	}

	}
}
